package com.CloudDream.Util;

import com.CloudDream.MoonCake;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class TextUtil {

    public static MoonCake instance = MoonCake.getInstance();
    private static String m = "Message.";

    public static String ReplaceText(String Text) {
        return Objects.requireNonNull(instance.getConfig().getString(Text)).replace("&", "§");
    }

    public static List<String> ReplaceTexttoList(String Text) {
        return instance.getConfig().getStringList(Text).stream()
                .map(lore -> lore.replace("&", "§"))
                .collect(Collectors.toList());
    }

    public static String ReplaceTextAll(Player t, String MoonCake) {
        return instance.getConfig().getString(m + ".Send-MoonCake").replace("&", "§").replace("{player}", t.getName()).replace("{mooncake}", MoonCake);
    }

    public static String ReplacePlayer(String config, String p) {
        return instance.getConfig().getString(m + config).replace("&", "§").replace("{player}", p);
    }
    public static boolean ReplaceItem( ItemStack item, String name) {
        return item.getItemMeta().getDisplayName().equals(ReplaceText(name));
    }
}
